package com.lanyuan.thrid.wechat.utils;

import java.util.Map;

import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheManager;

import com.lanyuan.util.ApplicationUtil;

public class WechatManager {

	private static CacheManager cacheManager;
	private static Cache<String, String> cache;
	static {
		if (cacheManager == null) {
			cacheManager = (CacheManager) ApplicationUtil.getBean("cacheManager");
		}
		cache = cacheManager.getCache("access_token_jsapi_ticket");
	}

	public static String getAccess_token() {
		// if (StringUtils.isEmpty(cache.get("access_token"))) {
		// Map<String, String> result = Api.token();
		// System.out.println("==================重新设置access_token=================");
		// cache.put("access_token", result.get("access_token"));
		// }
		// System.out.println("==================获取缓存中access_token=================");
		Map<String, String> result = Api.token();
		return result.get("access_token");
	}

}
